#include <stdio.h>
void Qsort(int a[], int k)
{
	int low = 1;
	int high = k - 1;
	int pivot = a[k-1];
	while (low < high)
	{
		while (low < high && a[low] < pivot) low++;
		a[high] = a[low];
		while (low < high && a[high] >= pivot) high--;
		a[low] = a[high];
	}
	a[low] = pivot;
	for (int i = 1; i < k; i++)
	{
		if (i == k - 1)
			printf("%d\n", a[i]);
		else
			printf("%d ", a[i]);
	}
}
int main()
{
		int k = 1;
		int a[10000] = { 0 };
		int num;
		while (scanf("%d", &num) != EOF)
		{
            if (num == -1)
            {
             	Qsort(a, k);
                k=1;
            }
            else
			  a[k++] = num;
		}
	return 0;
}
